package com.test.ssm.controller;

import com.test.ssm.pojo.ClassInfo;
import com.test.ssm.pojo.User;
import com.test.ssm.service.ClassInfoService;
import com.test.ssm.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 徒有琴
 */
@Controller
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private ClassInfoService classInfoService;

    @RequestMapping("/index.html")
    public String index(HttpSession session, Model model){
        User user = (User) session.getAttribute(Constants.SESSION_USER);
        List<ClassInfo> classInfoList=classInfoService.getClassList(user.getId());
        model.addAttribute("classes",classInfoList);
        return "teacher/index";
    }

}
